home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 1300 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: scms.rgu.ac.uk!dracon!cs2lk
  2. From: cs2lk@scms.rgu.ac.uk (Lee Kindness)
  3. Newsgroups: comp.sys.amiga.programmer,uiuc.class.cs110c,uiuc.class.cs223
  4. Subject: Re: How do I define my integers?
  5. Followup-To: comp.sys.amiga.programmer,uiuc.class.cs110c,uiuc.class.cs223
  6. Date: 17 Jan 1996 14:28:36 GMT
  7. Organization: The Robert Gordon University, School of Computer and Mathematical Sciences, Aberdeen, Scotland
  8. Message-ID: <4dj12k$pe1@roadkill.scms.rgu.ac.uk>
  9. References: <4d73ug$25v@vixen.cso.uiuc.edu>
  10. NNTP-Posting-Host: cs2lk%@dracon.scms.rgu.ac.uk
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. howard daniel joseph (djhoward@ux5.cso.uiuc.edu) wrote:
  14. :     Okay. I'm writing a program under GCC on my Amiga.
  15. :     But I'm confused to hell over integer limits.
  16. :     My book talks about 2 bit and 4 bit integers ... and four bit 
  17. : integers like what it describers long integers to be. Of course there's 
  18. : unsigned integers and the like too.
  19.  
  20. I'll explain it normall C way first followed by the Amiga includes
  21. standard in brackets.
  22.  
  23. : How do I declare signed versus unsigned integers?
  24.  
  25. Signed by default, add "unsigned" to make unsigned, eg
  26.  
  27. int i; // Signed integer
  28. signed int i2; // Signed integer
  29. unsigned int i3; // Unsigned integer
  30.  
  31. : How do I know how many bits my integers are using?
  32.  
  33. You can really do it explicitly, best to read the compiler documentation.
  34. However on the Amiga:
  35.  
  36. short = 2
  37. long = 4
  38. (plain int = 2 or 4 depending on compiler, options)
  39.  
  40. : How do I declare signed and unsigned long integers?
  41.  
  42. long int i; // Long signed integer
  43. (LONG i; //Long signed integer)
  44. unsigned long int i1; // unsigned long integer
  45. (ULONG i1; // unsigned long int)
  46.  
  47. : What's with these "doubles" the book mysteriously alludes to?
  48.  
  49. Similar to float but greater precision.
  50.  
  51. : What *am* I creating when I type;
  52.  
  53. : int somevalue;
  54. : (ie Is it signed/unsigned? How many bits?)
  55.  
  56. Normally signed, 4 bits on the Amiga.
  57.  
  58. : An integer (unsigned) that can handle, 6, though ideally 9 places (Just 
  59. : under 250000000 would be the maximum forseen possible value here.)
  60. : An integer that can handle a much bigger number ... 12 places at least for 
  61. : now.
  62.  
  63. Simply 2^32 is as much as you can bung into a "unsigned long int"
  64.  
  65. : Can I perform simple maths (addition, division) between integers of 
  66. : different types? I'd assume so, right?
  67.  
  68. Yup.
  69.  
  70. --
  71. \ Lee Kindness
  72.  \ wangi@frost3.demon.co.uk
  73.   \ cs2lk@scms.rgu.ac.uk
  74.    \ Current Amiga projects - Tenodif, GMulti, NLFind, FindXXX, GFindXXX
  75.     \=> Trumpet Blower!
  76.  
  77.